package com.pronosticos.reportes.dao.impl;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.pronosticos.reportes.dao.TblProductoDAO;
import com.pronosticos.reportes.entity.TblProductos;

@Transactional
@Repository
public class TblProductoDAOImpl extends GenericDaoImpl<TblProductos, Long>
implements TblProductoDAO {

    public TblProductoDAOImpl() {
        super(TblProductos.class);
    }

    public TblProductoDAOImpl(final Class<TblProductos> clazz,
            final SessionFactory sessionFactory) {
        super(TblProductos.class, sessionFactory);
    }

    @Override
    public Integer getConteo() {

        final Session session = sessionFactory.getCurrentSession();
        final Query q = session
                .createQuery("select count(u) from TblProductos u");
        final Number count = (Number) q.uniqueResult();
        return count.intValue();

    }

}
